package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.api.admin.AdSensitiveControllerApi;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "关键词模块")
@RequestMapping("/api/v1/sensitive")
public class AdSensitiveController implements AdSensitiveControllerApi {
    @Autowired
    AdSensitiveService adSensitiveService;
    /**
     * 根据名称分页查询频道列表
     *
     * @param dto
     * @return ResponseResult<List < AdChannel>>数据列表
     */
    @Override
    @PostMapping("/list")
    @ApiOperation("分页查询")
    public ResponseResult<List<AdSensitive>> findByNameAndPage(@RequestBody SensitiveDto dto) {
        return adSensitiveService.findByNameAndPage(dto);
    }

    /**
     * 插入数据
     *
     * @param adSensitive
     * @return 是否插入成功
     */
    @Override
    @PostMapping("/save")
    @ApiOperation("添加数据")
    public ResponseResult insert(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.insert(adSensitive);
    }

    /**
     * 修改数据
     *
     * @param adSensitive
     * @return 是否修改
     */
    @PostMapping("/update")
    @Override
    @ApiOperation("修改数据")
    public ResponseResult update(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.update(adSensitive);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    @Override
    @ApiOperation("删除数据")
    public ResponseResult deleteById(@PathVariable("id") Integer id) {
        return adSensitiveService.deleteById(id);
    }
}
